Video coding

ABSTRACT

Pictures are coded using a coding algorithm with a variable parameter QP so that the quality of the coding varies. First ( 100 ), a target value T iMOS  is specified for a quality measurement parameter. Then, for each picture (or part of a picture) to be coded, one estimates, independently of the other pictures, a value for the variable parameter QP based on a) the target value for that picture area and b) a masking measure C that depends on the picture content of that picture area. The picture is then coded ( 112 ) using the estimated value. The masking measure may be compensated ( 108, 122 ) to allow for the effect of the coding quality upon the masking effect.

The present invention is concerned with video coding.

The present invention is defined in the claims

Some embodiments of the invention will now be described with reference to the accompanying drawings, in which:

FIG. 1 is a block diagram of a video coder;

FIGS. 2 and 3 are flowcharts explaining the operation of the coder of FIG. 1; and

FIG. 4 is a graph showing the derivation of certain parameters.

The apparatus shown in FIG. 1 comprises a video interface 1 that receives digitally coded video signals, in uncompressed form, at a video input 2. A processor 3 operates under control of programs stored in disc storage 4 and has access to memory 5 and a video output buffer 6 that feeds a video output 7. The memory 5 includes a memory area 51 for temporary storage of picture parameters. The programs include a general purpose operating system 40 and video coding software which implements one of more of the coding methods shortly to be described. This software comprises several programs (or groups of programs), namely

-   -   control software 41;     -   compression software 42: in this example the compression         software implements a coding algorithm compliant with the ITU         H.264 standard;     -   perceptual quality evaluation software 43.

A video coding method according to a first version of the invention will be described with reference to the flowchart of FIG. 2. Firstly, however, the principles of operation will be explained.

The objective of the method is to code the video signals with constant quality. In principle we envisage coding each picture in such a way that the value of a quality parameter for that picture is equal to a target value for the quality parameter, or at least, such as to tend to reduce deviations from that target. We may specify a single target value that remains fixed, or if desired one may specify different target values for different pictures: for example in H.264 one might specify one target value for intra-coded pictures (I-picture), another for pictures coded using forward prediction (P-pictures) and a third for bidirectionally-coded pictures (B-pictures). It is also possible that one may wish to change the target value to accommodate the characteristics of some external system, for example a part of a congestion control mechanism. We prefer to use a perceptual quality measure, that is to say, a measure which takes account of masking effects.

The quality is controlled by providing that the coding algorithm has at least one variable parameter that influences the quality of the decoded picture—in this example it is the quantiser index. In H.264 the relationship between the quantiser index QP and the scaled quantiser step size QSS is given, for picture k, by

QSS(k)=2^(QP(k)/6)  (1)

Thus, the primary task of the control software 41 is to estimate a value for QP that would, were the quality of the decoded picture to be measured, result in a value for the quality measurement parameter that is equal, or close to, the target value. Whilst it would in principle be possible to determine this by coding the picture using a variety of different values of quantiser index, decoding the picture and computing the value of the quality measurement parameter of the decoded picture, we prefer to estimate QP from a known relationship among QP, the value of the quality measurement parameter, and a masking term.

One such relationship is described in our co-pending international patent application no. WO2007/066066. In that method, a quality measure was based on the quantiser step size parameter, and a measure of spatial complexity of the decoded picture. More specifically, in the case of an H.264 signal, a decoder delivered for each picture

(a) a quantiser step size parameter Q(i,j) (i=0, . . . , M_(x)−1; j=0 . . . M_(y)−1) for each macroblock i,j; (b) a decoded brightness value D(x,y) (x=0, . . . , P_(x)−1; y=0, . . . , P_(y)−1) for each pixel x,y.

A picture-averaged quantiser step size QPF was computed:

$\begin{matrix} {{QPF} = {\frac{1}{M_{x}M_{y}}{\sum\limits_{i = 0}^{M_{x} - 1}{\sum\limits_{j = 0}^{M_{y} - 1}{Q\left( {i,j} \right)}}}}} & (2) \end{matrix}$

As a masking measure, a contrast measure was used, representative of the difference between the average brightness over a small horizontal window of width H and that over a similar horizontally adjacent window:

$\begin{matrix} {C_{h} = {\frac{1}{H}{{{\sum\limits_{u = 0}^{H - 1}{D\left( {{x - u},y} \right)}} - {\sum\limits_{u = 0}^{H - 1}{D\left( {{x + u + 1},y} \right)}}}}}} & (3) \end{matrix}$

-   -   and similarly in the vertical direction:

$\begin{matrix} {C_{v} = {\frac{1}{V}{{{\sum\limits_{v = 0}^{V - 1}{D\left( {x,{y - v}} \right)}} - {\sum\limits_{v = 0}^{V - 1}{D\left( {x,{y + v + 1}} \right)}}}}}} & (4) \end{matrix}$

where V is the vertical window height, these two measures being combined so that the larger takes effect:

C _(hv)=Max(C _(h) C _(v))  (5)

A picture-averaged contrast measure CS was computed:

$\begin{matrix} {{CS} = {\frac{1}{P_{x} - {2H} + 1} \cdot \frac{1}{P_{y} - {2V} + 1} \cdot {\sum\limits_{x = {H - 1}}^{P_{x} - H - 1}{\sum\limits_{y = {V - 1}}^{P_{y} - V - 1}{C_{hv}\left( {x,y} \right)}}}}} & (6) \end{matrix}$

These two quantities were then time averaged over the time interval for which the MOS estimate is required: in the present case of course this is not required as the interval is that of a single picture.

The quality measure iMOS (instantaneous mean opinion score) is then formed as a weighted sum of these, using weighting factors obtained by regression analysis of training sequences of known subjective quality.

iMOS=−0.135×QPF+0.04×CS+7.442  (7)

This result was clamped to the range 0 to 5:

if (iMOS>5) then iMOS=5  (8)

if (iMOS<0) then iMOS=0  (9)

In the present case, the target value T_(iMOS) is specified, and we require to calculate QP. One option would be to invert the linear relationship of Equation (7), viz.:

$\begin{matrix} {{QPF} = \frac{{0.04 \times {CS}} + 7.442 - T_{iMOS}}{0.135}} & (10) \end{matrix}$

T_(iMOS) is in the range 0 to 5 and is not necessarily an integer (and in most instances will not be).

We prefer, however, to use a nonlinear model, and have chosen a quadratic representation. Other nonlinear representations are possible; for example, a relationship containing linear and logarithmic functions of the quantiser index has been tried, and could be used provided one is prepared to use numerical methods for solving it. The quadratic model is:

iMOS=aQP ² +bQP+c ₁ C+c ₂  [11]

Empirical values for the constants, obtained by analysing the results of subjective tests on decoded pictures obtained from coded training sequences of video are a=−00503; b=0.1742; c₁=0.072; c₂=2.649. Note that the masking measure C is calculated slightly differently from CS (though the latter could also be used if desired). The quadratic model has the advantage that it has an analytical solution so that the value of QP for a quality equal to the target can be obtained by application of the usual formula for solution of quadratic equations, giving:

$\begin{matrix} {{QP} = \frac{{- b} - \sqrt{b^{2} - {4{a\left( {{c_{1}C} + c_{2} - T_{iMOS}} \right)}}}}{2a}} & \lbrack 12\rbrack \end{matrix}$

The contrast measure C is a measure of the masking capability of the picture and is calculated as follows. For each luminance pixel, a block of 8 pixels to the left of the pixel is considered and the average is calculated. The pixel's contrast is set to the absolute value of the difference between this average and the pixel value. Using the same notation as above, then this gives

$\begin{matrix} {{C\left( {x,y} \right)} = {{{D\left( {x,y} \right)} - {\frac{1}{H}{\sum\limits_{u = 1}^{H}{D\left( {{x - u},y} \right)}}}}}} & \lbrack 13\rbrack \end{matrix}$

where in this example the block length H=8.

The average contrast for the whole picture is calculated as the average of the contrast values for the pixels whose blocks remain within the picture area when calculating the individual pixel contrast values:

$\begin{matrix} {C = {\frac{1}{P_{x} - 8} \cdot \frac{1}{P_{y}} \cdot {\sum\limits_{y = 0}^{P_{y} - 1}{\sum\limits_{x = 8}^{P_{x} - 1}{{{D\left( {x,y} \right)} - {\frac{1}{H}{\sum\limits_{u = 1}^{H}{D\left( {{x - u},y} \right)}}}}}}}}} & \lbrack 14\rbrack \end{matrix}$

In the system described in our earlier patent application, the contrast measure was obtained from the pixels D(x,y) of the decoded picture. Here, however, the decoded picture is not available until encoding has been performed and we therefore use the pixel luminance values A(x,y) of the uncoded source picture. The picture averaged contrast measure C_(SOURCE) for the source picture is thus

$\begin{matrix} {C_{SOURCE} = {\frac{1}{P_{x} - 8} \cdot \frac{1}{P_{y}} \cdot {\sum\limits_{y = 0}^{P_{y} - 1}{\sum\limits_{x = 8}^{P_{x} - 1}{\begin{matrix} {{A\left( {x,y} \right)} -} \\ {\frac{1}{H}{\sum\limits_{u = 1}^{H}{A\left( {{x - u},y} \right)}}} \end{matrix}}}}}} & \lbrack 15\rbrack \end{matrix}$

This value can be used in Equation 12 in place of C. However, whilst if a fine quantiser is used (i.e. with a small quantiser index and step size) the masking effect observed in the decoded picture is much the same as that in the original picture, at coarser quantisations the masking effect will be modified. Therefore in the preferred version of the invention we apply a correction to take account of the fact that the masking effect is modified in dependence on the quantiser index used. Since however the quantiser index is not known in advance, we base this correction on the empirically observed correlation between C, C_(SOURCE) and T_(iMOS):

One method of doing this us to use a linear (or other) model of this:

C _(CORR) =α+βT _(iMOS) +γC _(SOURCE)  [16]

where α=−4; β=1; γ=0.9 are empirical coefficients. These coefficients were estimated by the following procedure: (i) Seventeen video sequences, covering different types of material, were used, totaling 5958 pictures. These were coded using 32 different quantisation indices ranging from 20 to 51, and decoded. This gave 32 results per picture, but to reduce the amount of data, only one result, with a random QP, was retained for each picture. (ii) For each of these pictures, the source contrast measure CSOURCE and coded contrast C were calculated in accordance with equations 14 and 15. The quality iMOS was calculated in accordance with equation 11. (iii) It would be possible simply to apply regression techniques to the entire data set to estimate the parameters for equation (16). However, we proceeded by performing 26 separate regression analyses, each for a range of seven values of QP (20 to 26; 21 to 27; etc.). This gave 26 values for the coefficients α, β, γ and FIG. 4 is a graph showing these plotted against QP. (iv) The values chosen are representative values taken from the central region of the graphs.

In practice however, when the (or a) previous picture has already been coded using the same target iMOS, we prefer to use a different approach. When each picture has been decoded, we determine the value of C using Equation (14) and store T_(iMOS) (unless it is always constant), C_(SOURCE) and C. In order to compute C_(CORR) for a new picture, given C_(SOURCE) for the new picture, we use

$\begin{matrix} {C_{CORR} = {C_{SOURCE}\frac{C_{P}({iMOS})}{C_{PSOURCE}({iMOS})}}} & \lbrack 17\rbrack \end{matrix}$

where C_(PSOURCE)(iMOS) and C_(P)(iMOS) are the source and coded contrast respectively for the previously coded and decoded picture. The previous picture selected for this purpose can be the immediately preceding picture, or (if the immediately preceding picture did not use the same target iMOS) the most recent picture that did use the same target iMOS. By “immediately preceding” and “most recent” we mean, when considered in order of coding; however an alternative would be to select the immediately preceding or most recent picture, considered in display order, of those frames that have already been coded. Note also that a previously coded picture with a target iMOS that is not the same as, but within a small tolerance (say ±0.2); thus it is sufficient that the candidate picture has a similar T_(iMOS) to the new picture (this is also true of the alternative approaches discussed below). Other approaches to this selection will be discussed later. In any case where C_(PSOURCE)(iMOS) and C_(P)(iMOS) are not available, then the relation of Equation 16 is used instead. Where only a single value for T_(iMOS) is specified, this will be the case only for the first frame. If, in the alternative, C_(SOURCE) is used uncorrected for the first frame to be coded with a specified T_(iMOS), subsequent repeated use of Equation 17 for subsequent frames to be coded with the same T_(iMOS) should gradually reduce errors in the masking correction.

Referring now to FIG. 2, at Step 100, a signal is received stipulating a target value T_(iMOS). At step 102 a digitally coded picture is received at the input 1 and stored in the memory 5. Then (104) the picture is analysed in accordance with Equation (15) to determine C_(SOURCE). At 106 a check is performed as to whether there are stored data in the memory area 51 for the current T_(iMOS). The first time this test is performed there will not be; thus at 108 a masking value C_(CORR) is calculated in accordance with Equation (16). Next, in Step 110, the quantiser index to be used is computed in accordance with equation (12), using C_(CORR) instead of C. Then, at Step 112 the picture is coded using the H.264 software 42 with this quantisation index and sent to the output buffer 6. The coded picture is decoded (114) in accordance with H.264 and then analysed (116) according to Equation (14) to obtain the decoded value for C. At Step 118, various data for the decoded picture the picture number are stored in the memory area 51 for future use. The precise data required will depend on which strategy is in use for determining which previously coded and decoded picture is to be used for applying equation (17). They will include some or all of the following: the picture number in coding order; the picture number in display order; T_(iMOS); C_(SOURCE); C; and picture type (I, P or B).

The process then returns to Step 102 to receive another picture, which is processed in the same way. However, in the event that, at Step 106, it is found that one or more pictures have previously been coded with the current value of T_(iMOS), then, instead of Step 108, the masking value C_(CORR) is obtained at Step 120 by looking up the values of C_(PSOURCE)(iMOS) and C_(P)(iMOS) for a selected previously coded and decoded picture, and applying Equation (17). Then the process continues from Step 110.

Some selection options for the previously coded and decoded picture to be used at Step 120 have been discussed earlier. Other approaches that take cognisance of the possibility that the most recent picture is not necessarily the most similar to the picture to be coded will now be described. One possibility is to use the most recent (in either sense) picture of the same type; in one example, if the current picture is a B-picture we use the most recent B-picture, if the current picture is P or I picture we use the most recent picture that is not a B picture (in other words, P and I pictures are considered to be of the same “type” for this purpose).

For a BBPBBP coding structure, the first three of these options give the following output, with pictures listed in coding order and numbered in display order.

Recent Previous Previous Source Previous Displayed Coded Same Picture Coded Picture Picture Type I2 B0 I2 I2 I2 B1 B0 B0 B0 P5 B1 I2 I2 B3 P5 I2 B1 B4 B3 B3 B3 P8 B4 P5 P5 B6 P8 P5 B4 B7 B6 B6 B6 P11 B7 P8 P8 B9 P11 P8 B7 B10 B9 B9 B9 P14 B10 P11 P11

Note that the only difference between “previous output picture” and “previous coded same type” is for the first B picture in each grouping. In the former case the previous picture is the I or P picture coded four periods ago but displayed immediately previously, and in the latter case it is the last B picture of the last grouping, coded and displayed two periods ago.

Another option is to search among the previously coded and decoded pictures to find one that is similar to the picture currently to be coded. Typically this would be over a short time window, of perhaps one second or a few seconds. One possible criterion of similarity for this purpose is to search for a previously coded and decoded picture that has a value for source contrast C_(SOURCE) closest to that of the current picture. The following macro FindSimilar may be used to find the most similar source contrast in the previous R encoded pictures, by comparing the current picture's source contrast with the source contrast of each of the previous R coded pictures.

The implementation of the FindSimilar macro is shown below, where r is the picture number, the first picture being coded with the specified T_(iMOS) having r=1.

Sub FindSimilar( ) current = csource(r) best_r = r − 1 best_error = abs(current − csource(best_r)) for other_r = r − 2 TO r − R step −1 if (other_r >= 6) then this_error = abs(current − csource(other_r)) if (this_error < best_error) then best_r = other_r best_error = this_error end if end if next other_r result = best_r next row End Sub

Another option for finding the most similar recent picture is to actually compare the pictures themselves—though this is much more demanding on processing power. If this option is used, it is necessary to have access to these pictures, so unless the pictures are already available (for example if the entire sequence to be coded is already stored on the disc 4), then Step 118 would need to store also the entire picture.

We suppose that there are M pictures in the buffer. The current picture is referred to as picture zero, the most recently coded picture is picture 1 and the oldest is picture M. At Step 200, a pointer m is set to M. B, which is to contain the number of the picture that best matches the current one, is set to zero.

At Step 202, the stored T_(iMOS) for frame m is compared with that for the current picture and if they are unequal, m is decremented at Step 204 and the process repeated from step 202, unless (206) all the stored pictures have been examined, in which case the process terminates.

If a match occurs at Step 202 picture m is compared (210) with the current picture to obtain the sum of absolute differences Δ(m):

$\begin{matrix} {{\Delta (m)} = {\sum\limits_{y = 0}^{P_{y} - 1}{\sum\limits_{x = 0}^{P_{x} - 1}{{{A_{m}\left( {x,y} \right)} - {A_{0}\left( {x,y} \right)}}}}}} & (18) \end{matrix}$

If this is less that the sum of absolute differences Δ(B) obtained for the best picture so far, then at Step 212, B is set equal to m. Either way the process then proceeds to Step 204. Upon exit at Step 206, the pointer B will contain the picture number m for the picture that has the best match with the current one, and this one is chosen. The only exception is when there are no previously coded pictures with the same target iMOS as the current one. Then B=0 and is set to 1 (step 214) so that the immediately preceding picture is chosen by default.

If desired, these search methods could be limited to searching for a picture of the same type (B or UP) as the current one.

We have discussed a number of methods of selecting a previously coded and decoded picture. One may also use a combination of the different methods. one preferred method, shown in the code below, is as follows. First, consider the previous picture of the same type (i.e. B or non-B), and if the source contrast of that picture is similar to the current, then use it. Otherwise, consider the previous picture of the other type (non-B or B respectively), and if the source contrast of that picture is similar to the current (i.e. within a defined tolerance of—say ±20%), then use it. Otherwise, if the source contrast of either of these previous pictures is similar to that of the current picture (with a wider tolerance—e.g. ±50%), choose the most similar (i.e. with the source contrast that is closest to that of the current picture). (Note that the tolerances used below are slightly different; the criterion used for comparing two contrasts is that they are deemed similar if the ratio of the larger to the smaller is less that 1.25 (or 2.0 for the wider tolerance). Otherwise use the (single frame) method of equation 16.

Initialisation code // Set the following to an arbitrary large negative number to show that they are not valid CurrentSourceContrast = −100.0; PreviousPSourceContrast = −100.0; PreviousBSourceContrast = −100.0; PreviousPCodedContrast = −100.0; PreviousBCodedContrast = −100.0;

Per picture code (only shown for B pictures, similar code in an else statement for I/P pictures). Note “break” means jump out of the “while” loop, which is not actually a loop but a means to avoid unfashionable “goto” statements.

if (H264_B_SLICE == m_SliceType) { while (true) { double b_ratio = 0.001; double p_ratio = 0.001; if (PreviousBSourceContrast > 0.0) { b_ratio = CurrentSourceContrast / PreviousBSourceContrast; if ((b_ratio <= 1.25) && (b_ratio >= 0.8)) { // Previous B source contrast is calculated, and current source contrast is similar. // Assume that the ratio of contrast of the current coded B frame to source frame will // be the same as for the previous B frame pqos_contrast = b_ratio * PreviousBCodedContrast; break; } } if (PreviousPSourceContrast > 0.0) { p_ratio = CurrentSourceContrast / PreviousPSourceContrast; if ((p_ratio <= 1.25) && (p_ratio >= 0.8)) { // Previous P source contrast is calculated, and current source contrast is similar. // Assume that the ratio of contrast of the current coded B frame to source frame will // be the same as for the previous P frame pqos_contrast = p_ratio * PreviousPCodedContrast; break; } } if (((b_ratio <= 2.0) && (b_ratio >= 0.5)) ∥ ((p_ratio <= 2.0) && (p_ratio >= 0.5))) { // At least one of the ratios is within a factor of two, so use the better one if ((b_ratio + (1.0 / b_ratio)) < (p_ratio + (1.0 / p_ratio))) { pqos_contrast = b_ratio * PreviousBCodedContrast; break; } else { pqos_contrast = p_ratio * PreviousPCodedContrast; break; } } // Conclude that the previous frames' contrast is too different from the current frame's to be useful, // so use an intra-frame method instead pqos_contrast = target_imos + (0.9 * CurrentSourceContrast) − 4.0; break; } } // END OF: if (H264_B_SLICE == m_SliceType)

Variations

It was mentioned above that the coding algorithm to be used has at least one variable parameter, and the quantisation index was given as an example. It is also possible to vary the coding by reducing the spatial resolution, as by subsampling or by discarding transform coefficients.

The H.264 standard permits different macroblocks (16×16 pixels) within a picture to be assigned different quantiser stepsizes. If desired, the processes described above for determining the quantiser index to be used for a picture could equally well be applied to a part of a picture such as an individual macroblock separately. This could be done even if the same target quality were specified for the whole picture, as it could still result in different quantiser indices for the different macroblocks, if the masking effects vary. Also it admits of the possibility of specifying different target values for different macroblocks (e.g. for an intra-macroblock or a inter-macroblock). Indeed, this could be done on a macroblock-by macroblock basis even if the masking is estimated only for the whole picture.

Also, the selection could be made on some other criterion, such as based on focus of attention: parts of the picture the viewer is not going to focus on do not need to be coded as well as the areas of interest where he will be focussed. Region-of-interest coding is discussed in D. Agrafiotis, S. J. C. Davies, N. Canagarajah and D. R. Bull, “Towards efficient context-specific video coding based on gaze-tracking analysis”, ACM Transactions on Multimedia Computing, Communications, and Applications (TOMCCAP), Volume 3, Issue 4 (December 2007); Crabtree, B. “Video compression using focus of attention”, Proceedings of the Picture Coding Symposium, China 2006; and our international patent application no WO01/61648.

It is also possible to apply different quantiser step sizes to different coefficients within a macroblock. A quantisation index is specified and then adjusted for different coefficients by application of a matrix. This is described in detail in the MPEG2 and H.264 standards.

It will often arise the value for the quantisation index obtained by the use of Equation (12) is not an integer. For many purposes it will be sufficient simply to round this to the nearest integer. However, in the event that it is desired to achieve an average quantisation index over the picture that is equal to the non-integer value obtained, one may proceed as follows A macroblock is a 16×16 picture area. It is the smallest area of picture that can have an independent value of quantisation index. If the value of average_quantiser calculated at the start of the picture (i.e. QP) is an integer, then all that is needed at this point is to set the quantiser index for each macroblock to this integer value. If it is not an integer, such as 32.5, then it is necessary to vary the quantiser index for each macroblock. In this case there are many ways that this could be done, for example to use 32 for the top of the picture and 33 for the bottom. However, such a strategy may have visible effects as the top of the picture may look better than the bottom. An alternative is to alternate 32, 33, 32, 33 etc.

However, this alternating pattern also has problems. When a macroblock is skipped (not coded), no information is present in the encoded bitstream for the macroblock, and it is not possible to change the quantisation index. Hence if the second macroblock were skipped, then setting the quantisation index to 32, 33, 32, 33, would result in the pattern 32, 32, 32, 33 being received at the decoder, and the average value would be calculated as 32.25 not 32.5 as planned.

So it is necessary to keep track of the values of quantisation index that the decoder would decode from the bitstream, and ensure that the average value at the decoder was as intended.

The following pseudo-code shows how this was implemented.

Set total_number_of_macroblocks to the total number in the picture Set number_of_macroblocks_left to the number still to be encoded Set total_quantiser to the sum of quantiser indices so far in the picture Set quantiser_remainder to zero average_quantiser_from_here = (total_number_of_macroblocks * average_quantiser − total_quantiser) / number_of_macroblocks_left this_quant = (int) (average_quantiser_from_here + quantiser_remainder + 0.5) Clip this_quant to +/− 3 from average_quantiser to prevent extreme values towards the end of the picture. quantiser_remainder = quantiser_remainder + average_quantiser_from_here − this quant 

1. A method of video coding using a coding algorithm having a variable parameter influencing the quality of the coding, the method comprising specifying at least one target value for a quality measurement parameter, so that each picture or part of a picture has such a target value; for each picture area to be coded, where a picture area may be a picture or part of a picture, performing the steps of: estimating, independently of the other pictures, a value for said variable parameter based on (a) the target value for that picture area and (b) a perceptual masking measure dependent on the picture content of that picture area, in accordance with a predetermined relationship between those quantities; and coding the picture area using the estimated value.
 2. A method according to claim 1 in which the masking measure is generated, before coding the picture area, from pixel values of the picture to be coded.
 3. A method according to claim 2 in which the masking measure is a measure of spatial complexity of the picture area.
 4. A method according to claim 2 in which the masking measure is generated, before coding the picture area, by deriving a source masking measure from pixel values of the picture to be coded and modifying this measure in accordance with an estimate of the effect of the coding algorithm upon the degree of masking.
 5. A method according to claim 4 in which the masking measure is a function of a) the source masking measure and b) the target value of the quality measurement parameter for that picture area.
 6. A method according to claim 3 comprising, after coding a picture: generating a decoded version of the picture; determining a masking measure for the decoded picture; storing either (a) the masking measure for the decoded picture and the masking measure for the source picture or (b) data indicative of the relationship between the masking measure for the decoded picture and the masking measure for the source picture; and wherein the step of modifying the source masking measure for a picture area to be coded (other than the first) comprises scaling the measure in accordance with the relationship between the masking measure for a previously coded and decoded picture that was coded using the same, or a similar, target value of quality measurement parameter as the picture to be coded and the source masking measure for the same previously coded and decoded picture.
 7. A method according to claim 6 in which said relationship is the ratio of the masking measure for a previously coded and decoded picture and the source masking measure for the same previously coded and decoded picture
 8. A method according to claim 6 in which the previously coded and decoded picture is the most recent (considered in the order in which the pictures are coded) picture of a set of pictures that were coded with the same, or a similar, target value as the picture being coded.
 9. A method according to claim 6 in which the previously coded and decoded picture is the most recent (considered in the order in which the pictures are to be displayed) picture of a set of pictures that were coded with the same, or a similar, target value as the picture being coded.
 10. A method according to claim 6 further including comparing the picture to be coded with a set of pictures that have previously been coded; and selecting one of the previously coded pictures that has a high similarity to the picture being coded; wherein the relationship used for scaling of the source masking measure for the picture being coded is that of the selected picture.
 11. A method according to claim 10 in which the degree of similarity between the picture being coded and a previously coded picture is determined by comparing the source masking measures of the two pictures.
 12. A method according to claim 10 in which the degree of similarity between the picture being coded and a previously coded picture is determined by comparing pixel values of the two pictures.
 13. A method according to claim 8 in which the set of pictures is a predetermined number of pictures, being the most recent pictures that were coded with the same, or a similar, target value as the picture being coded.
 14. A method according to claim 8, in which the set of pictures is a predetermined number of pictures, being a selection from the most recent pictures that were coded with the same, or a similar, target value as the picture being coded, the selection being based on the prediction type of the picture being coded.
 15. A method according to claim 14 in which in the event that the picture to be coded is to be coded using bidirectional prediction, the set of pictures consists of pictures that were coded using bidirectional prediction and in the event that the picture to be coded is to be coded without using bidirectional prediction, the set of pictures consists of pictures that were coded without using bidirectional prediction.
 16. A method according to claim 1 in which the variable parameter is a quantisation parameter.
 17. A method according to claim 1 in which the predetermined relationship between the variable parameter, the quality metric and the masking measure is determined by analysis of the results of coding training sequences of video material. 